﻿using AutoMapper;
using WeatherHistory.Api.CommandsQueries.Mapping;
using WeatherHistory.Data.Entities;
using WeatherHistory.Shared.Extensions;

namespace WeatherHistory.Api.CommandsQueries.Queries.Forecasts.GetOne;

public class GetOneForecastsQueryResponse : IMapWith<Forecast>
{
    public long Id { get; set; }
    public string DateTime { get; set; } = null!;
    public float Temperature { get; set; }
    public string WeatherCondition { get; set; } = null!;
    public long RegionId { get; set; }

    public void Mapping(Profile profile)
    {
        profile.CreateMap<Forecast, GetOneForecastsQueryResponse>()
            .ForMember(dest => dest.Id,
                opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Temperature,
                opt => opt.MapFrom(src => src.Temperature))
            .ForMember(dest => dest.RegionId,
                opt => opt.MapFrom(src => src.RegionId))
            .ForMember(dest => dest.DateTime,
                opt => opt.MapFrom(src => src.Datetime.ToIso8601String()))
            .ForMember(dest => dest.WeatherCondition,
                opt => opt.MapFrom(src => src.WeatherCondition));
    }
}